﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using SelfService.Model.Models;


namespace SelfService.ViewModel.SysClientTaskVMs
{
    public partial class SysClientTaskListVM : BasePagedListVM<SysClientTask_View, SysClientTaskSearcher>
    {

        protected override IEnumerable<IGridColumn<SysClientTask_View>> InitGridHeader()
        {
            return new List<GridColumn<SysClientTask_View>>{
                this.MakeGridHeader(x => x.Action),
                this.MakeGridHeader(x => x.Status),
                this.MakeGridHeader(x => x.ClientName),
                this.MakeGridHeader(x => x.CreateTime),
                this.MakeGridHeader(x => x.UpdateTime),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<SysClientTask_View> GetSearchQuery()
        {
            var query = DC.Set<SysClientTask>()
                .Select(x => new SysClientTask_View
                {
				    ID = x.ID,
                    Action = x.Action,
                    Status = x.Status,
                    ClientName = x.Client.Name,
                    CreateTime = x.CreateTime,
                    UpdateTime = x.UpdateTime
                })
                .OrderBy(x => x.UpdateTime);
            return query;
        }
    }

    public class SysClientTask_View : SysClientTask{
        [Display(Name = "客户端")]
        public String ClientName { get; set; }

    }
}
